package cycling.taxi.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cycling.taxi.com.R;
import cycling.taxi.com.bean.SalesInfo;

import static android.R.attr.data;

/**
 * 售后服务的适配器
 * Created by Administrator on 2017/5/17.
 */

public class MyAfterAdapter extends BaseAdapter {

    private Context context;
    private List<SalesInfo> SalesInfos;
    public MyAfterAdapter(Context context, List<SalesInfo> SalesInfos){
        this.context=context;
        this.SalesInfos=SalesInfos;
    }
    @Override
    public int getCount() {
        return SalesInfos.size();
    }

    @Override
    public Object getItem(int arg0) {
        return SalesInfos.get(arg0);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyAfterAdapter.HolderView holderView=null;
        SalesInfo salesInfo=null;
        if (convertView==null) {
            holderView=new MyAfterAdapter.HolderView();
            convertView= LayoutInflater.from(context).inflate(R.layout.item_sales, null);
            holderView.iv=(ImageView) convertView.findViewById(R.id.iv);
            holderView.name=(TextView) convertView.findViewById(R.id.name);
            holderView.phone=(TextView) convertView.findViewById(R.id.phone);
            holderView.address=(TextView) convertView.findViewById(R.id.address);
            convertView.setTag(holderView);
        }else {
            holderView=(MyAfterAdapter.HolderView) convertView.getTag();
        }
        salesInfo=SalesInfos.get(position);
        holderView.iv.setImageResource(R.drawable.cycling_icon);
        holderView.name.setText("公司名称:"+salesInfo.getConmanyName());
        holderView.phone.setText("电话:"+salesInfo.getPhone());
        holderView.address.setText("地址:"+salesInfo.getAddress());

        return convertView;
    }
    public class HolderView {
        private ImageView iv;
        private TextView name;
        private TextView phone;
        private TextView address;
    }
}

